package annotation;

import java.lang.annotation.Annotation;
import java.lang.reflect.Method;

public class AnnotationParsing {
	
	public static void main(String[] args) {
		try {
			//getClassLoader().loadClass("类名").getMethods() 加载类名并
			for(Method method:AnnotationParsing.class
					.getClassLoader()
					.loadClass("annotation.AnnotationExample")
					.getMethods()) {
				if(method.isAnnotationPresent(annotation.MethodInfo.class)) {
					//获取方法上的注解
					for(Annotation anno:method.getDeclaredAnnotations()) {
						System.out.println("Annotation in Method '"
								+method+"' : "+anno);
					}
					MethodInfo methodAnno=method.getAnnotation(MethodInfo.class);
					if(methodAnno.revision()==1) {
						System.out.println("Method with revision no 1 = "+method);
					}
				}
			}
		}catch(Exception ex) {
			ex.printStackTrace();
		}
	}
	
}
